<?php
/**
 * 留言板
 */

namespace app\pc\model;


use app\common\model\Model;

class BulletinBoard extends Model
{

    const TABLE_NAME = 'bulletin_board';
    const CACHE_EXPIRE_LEVEL = self::CACHE_EXPIRE_LEVEL_4;

    protected $name = self::TABLE_NAME;

    public static function addRecord($option)
    {
        $data =[
            'record_name'=>$option['real_name'],
            'record_email'=>$option['email'],
            'record_gender'=>$option['gender']=='W'?2:1,
            'record_text'=>htmlspecialchars($option['content']),
            'record_time'=>time()
        ];

        if(!empty($option['address'])){
           $data['record_address']=$option['address'];
        }

        if(!empty($option['phone']))
        {
            $data['record_phone']=$option['phone'];
        }

        return   self::commonQuery(self::TABLE_NAME)
                ->insert($data,false,true);
    }
}